//
//  CustomTabbar.m
//  BeautifulLockerRoom
//
//  Created by mac on 16/7/30.
//  Copyright © 2016年 Winny. All rights reserved.
//

#import "CustomTabbar.h"

@interface CustomTabbar ()
{
    NSArray * imageArray;
    NSArray * imageArray1;
}
@end

@implementation CustomTabbar

- (void)viewDidLoad {
    [super viewDidLoad];
    UIView * footView = [[UIView alloc]initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height-50,[UIScreen mainScreen].bounds.size.width , 50)];
    [self.view addSubview:footView];
    imageArray = @[@"yuike_maintab_home_nor",@"yuike_maintab_ninenine_nor",@"yuike_maintab_gquality_nor",@"yuike_maintab_shopcart_nor",@"yuike_maintab_space_nor"];
    
    imageArray1 = @[@"yuike_maintab_home_sel",@"yuike_maintab_ninenine_sel",@"yuike_maintab_gquality_sel",@"yuike_maintab_shopcart_sel",@"yuike_maintab_space_sel"];
    
   
    for (int i = 0; i < 5; i++)
    {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.tag = i;
        
        [btn setImage:[UIImage imageNamed:imageArray[i]] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:imageArray1[i]] forState:UIControlStateSelected];
        btn.frame = CGRectMake(i*WINDOWWIDTH/5+WINDOWWIDTH/20,5,35, 40);
        
        
        
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        //btn.backgroundColor = [UIColor redColor];
        [footView addSubview:btn];
        if (i == 0)
        {
            btn.selected = YES;
            self.button = btn;

            
        }
        
    }
}

-(void)btnClick:(UIButton*)btn
{
    self.button.selected = NO;
    btn.selected = !btn.selected;
    self.button = btn;
    self.selectedIndex = btn.tag;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
